from django.db import models
from datetime import datetime
from enum import unique
from typing import Tuple
from django.db.models.deletion import CASCADE
#from django.utils import timezon
import hosSystem.models as models1

# Create your models here.
class Patients(models.Model):#病人注册信息
    id_patient=models.CharField(max_length=50,primary_key=True,verbose_name='id',db_column='id')#db_column设置表的列名
    name_patient=models.CharField(max_length=20,db_column='name')
    sex_patient=models.IntegerField(choices=((0,'男'),(1,'女')),default=0,db_column='sex') #'男''女'是在页面中显示的
    age_patient=models.IntegerField(null=True,db_column='age')
    contact_patient=models.CharField(max_length=20,null=True,db_column='contact')
    registerTime_patient=models.DateTimeField('%Y-%m-%d %H:%M:%S',auto_now_add=True,db_column='registerTime')#登陆时间自动填充
    class Meta:
        verbose_name='病人注册信息表'    

'''
class Doctors(models.Model):#医生信息 后台加入
    id_doctor=models.CharField(max_length=50,primary_key=True)
    name_doctor=models.CharField(max_length=20)
    sex_doctor=models.IntegerField(choices=((0,'男'),(1,'女')),default=0) #'男''女'是在页面中显示的
    age_doctor=models.IntegerField(null=True)
    type_doctor=models.CharField(max_length=10,choices=(
        ('emergency','急诊'),('department','科室'),('assay','化验'),('treat','治疗'),('impatient','住院'))
    )
    workplace_doctor=models.CharField(max_length=20,choices=(
        ('内科','内科'),('外科','外科'),('骨科','骨科'),('妇科','妇科'),('眼科','眼科'),('皮肤科','皮肤科'),
        ('中医科','中医科'),('疼痛科','疼痛科'),('口腔科','口腔科'),('耳鼻喉科','耳鼻喉科'),('急诊科','急诊科'),
        ('产科','产科'),('传染科','传染科'))
    )#工作科室 内科 外科
    cousulting_room=models.CharField(max_length=50)#诊室 具体的内科中的哪一科
    pwd_doctor=models.CharField(max_length=20)#医生的登录密码 入职时由后台确定
    class Meta:
        verbose_name='医生信息注册表'
'''

class IPD_devicestock(models.Model):  # 住院部设备库存
    nd_code = models.CharField(max_length=30, primary_key=True)
    name_device = models.CharField(max_length=30)
    manufacturer = models.CharField(max_length=30)
    storage = models.IntegerField()
    units_device = models.CharField(max_length=10)

class IPD_harmacy(models.Model):  # 住院部药房库存
    nd_code = models.CharField(max_length=30, primary_key=True)
    name_drug = models.CharField(max_length=30)
    manufacturer = models.CharField(max_length=30)
    storage = models.IntegerField()
    units_drug = models.CharField(max_length=10)

class Head_nurse(models.Model):  # 护士长注册信息
    id_nurse = models.CharField(max_length=50, primary_key=True)
    name_nurse = models.CharField(max_length=20)
    sex_nurser = models.IntegerField(choices=((0, '男'), (1, '女')), default=0)  # '男''女'是在页面中显示的
    age_nurse = models.IntegerField(null=True)
    workplace = models.CharField(max_length=20)
    pass

class InPatient(models.Model):  #住院信息

    id_inpatient = models.CharField(max_length=50, primary_key=True)
    id_doctor = models.ForeignKey(models1.Doctors,on_delete=CASCADE,null=True)
    name_surgery1 = models.CharField(max_length=50,null=True)#
    name_inpatient1 = models.CharField(max_length=50)
    age_inpatient = models.IntegerField(null=True)
    sex_inpatient = models.IntegerField(choices=((0, '男'), (1, '女')), default=0)
    contact_inpatient = models.CharField(max_length=20, null=True)
    number_bed1 = models.IntegerField(null=True)
    workplace_doctor = models.CharField(max_length=20, default='内科',choices=(
        ('内科', '内科'), ('外科', '外科'), ('骨科', '骨科'), ('妇科',
                                                   '妇科'), ('眼科', '眼科'), ('皮肤科', '皮肤科'),
        ('中医科', '中医科'), ('疼痛科', '疼痛科'), ('口腔科',
                                         '口腔科'), ('耳鼻喉科', '耳鼻喉科'), ('急诊科', '急诊科'),
        ('产科', '产科'), ('传染科', '传染科'),('化验科','化验科'))#化验科 验血 X光 核磁共振
    )  # 工作科室 内科 外科

    
class Surgery(models.Model):  #手术信息
	id_surgery = models.CharField(max_length=50, primary_key=True)
	name_surgery2 = models.CharField(max_length=50)
	name_inpatient2 = models.CharField(max_length=50)
	sex_surgery = models.IntegerField(choices=((0, '男'), (1, '女')), default=0)
	age_surgery = models.IntegerField(null=True)
	contact_isurgery = models.CharField(max_length=20, null=True)
	number_bed2 = models.IntegerField(null=True)

class IPD_fetchmedicine(models.Model):  #住院部取药信息
    id_fetchmedicine = models.CharField(max_length=50, null=False)
    id_pharmacydoctor = models.CharField(max_length=50, null=False)
    fetchTime = models.DateTimeField('%Y-%m-%d %H:%M:%S', auto_now_add=True)
    nd_code2 = models.CharField(max_length=30, primary_key=True)
    name_drug2 = models.CharField(max_length=30)
    units_device2 = models.CharField(max_length=10)
    class Meta:
        unique_together=(('id_fetchmedicine','id_pharmacydoctor','fetchTime'),)